package com.css.fxfzysx.modules.vabStructure.service.impl;

import com.css.fxfzysx.modules.vabStructure.service.SrcCommonService;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
@Service
public class SrcCommonServiceImpl implements SrcCommonService {
    @Resource
    private JdbcTemplate jdbcTemplate;

    @Override
    @Async
//    @Transactional(
//            value = "jpaTransactionManager",
//            rollbackFor = {Exception.class}
//    )
    public void updateEntirety(String modelId, String type) {
        StringBuffer sql = new StringBuffer("update czt_crs_calentirety_result set calculate_or_not = '0' ");
//        switch (type){
//            case "ms":
        if(type.equals("ms")) {
            sql.append("where cal_id = '"+modelId+"'") ;
        }
        if(type.equals("fv")) {
            sql.append("where fv_id = '"+modelId+"'");
        }
        if(type.equals("ci")) {
            sql.append("where cal_id in (select entirety_id from czt_crs_entirety_ci where ci_id = '"+modelId+"')" );
        }

//            case "fv":
//                sql.append("where fv_id = '"+modelId+"'");
//            case "ci":
//                sql.append("where cal_id in (select entirety_id from czt_crs_entirety_ci where ci_id = '"+modelId+"')" );
        jdbcTemplate.update(sql.toString());
    }
}
